package edu.nf.ch02.web.api;

import edu.nf.ch02.common.ResultVO;
import edu.nf.ch02.entity.Product;
import edu.nf.ch02.mapper.ProductMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author gjh
 * @Date 2025/9/17
 * @Description:
 */
@RestController
@RequestMapping("/api/v1")
@Tag(name = "用户服务接口",description = "提供用户信息相关的API操作接口")
public class ProductController {

    @Autowired
    private ProductMapper productMapper;

    @GetMapping("/product")
    @Operation(summary = "查询所有商品",description = "查询商城中所有商品信息",method = "GET")
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200",description = "响应成功"),
            @ApiResponse(responseCode = "500",description = "查询失败，服务端异常")
    })
    public ResultVO<List<Product>> listProduct() {
        return ResultVO.success(productMapper.productList());
    }
}
